var app = getApp();
var req = require("../../utils/req.js");
var url = require("../../utils/url.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isManage:false, //如果是店长
    isBoss:true, //如果是老板
    storeId:'',
    storeInfo:'',
    bussinessInfo:'',
    type:'',
    isChecked:true,
    isShow:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    app.globalData.storeId = options.id;
    app.globalData.storeState = null;
    that.setData({
      storeId: options.id
    });
    that.storeDetail();
  },
  onShow:function(){
    
  },
 /**
   * 获取店铺的详细信息
   */
  storeDetail:function(){
    var that = this;
    var data = {};
    var storeId = that.data.storeId;
    req.storeRequest("请稍等", "POST", url.store['getStoreInfo'],storeId,data,function back(res){
      console.log(res.data);

      app.globalData.storeInfo=res.data;
      that.setData({
        storeInfo:res.data[0],
        bussinessInfo:res.data[1]
      })
      if (that.data.storeInfo['state']!=1){
        that.setData({
          isChecked:false
        })
      }
      switch (that.data.bussinessInfo['type']) {
        case 0:
          that.setData({
            isManage: false,
            isBoss: true,
            isShow:true
          })
          break;
        case 1:
          that.setData({
            isManage: true,
            isBoss: false,
            isShow: true
          })
          break;
        default:
          that.setData({
            isManage: false,
            isBoss: false,
            isShow: false
          })
      }
    });
  },

  /**
   * 老板权限
   */
  gotoBoss:function(){
    var type = this.data.bussinessInfo['type'];
    var state = this.data.storeInfo['state'];
    if (app.globalData.storeState==null){
      if (state == 0) {
        app.globalData.storeState = true
      } else {
        app.globalData.storeState = false
      }
    }
    wx.navigateTo({
      url: '../permissionList/permissionList?type=' + type,
    })
  },
  goToWechat:function(){
    wx.navigateTo({
      url: '../setMonery/setMonery?type',
    })
  },
  /**
   * 消费记录
   */
  checkConsumption:function(){
    wx.navigateTo({
      url: '../checkConsumption/checkConsumption',
    })
  },
  /**
   * 赠送积分记录
   */
 sendIntegral:function(){
   wx.navigateTo({
     url: '../sendIntegral/sendIntegral',
   })
 },
 
})